package testUnit;

import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import FamilyTherapy.EventCard;

public class testEventCard {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}


	@Test
	public void testEventCard() {
		boolean isNEW=false;
		EventCard e=new EventCard(0);
		
		if(e!=null)
			isNEW=true;
		assertEquals(true,isNEW);

	}

	@Test
	public void testGetDescriptionInt() {
		final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
		System.setOut(new PrintStream(outContent));
		
		
		//if (newLine == null) newLine = "\n";
		
		EventCard e=new EventCard(1);
		e.getDescription(1);
		
		String expected = "Q2_Grandpa kisses Father\n" ;
		
		assertEquals(expected,outContent.toString());

	}

	@Test
	public void testDisplayChoiceDescription() {
		final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
		System.setOut(new PrintStream(outContent));
		

		//if (newLine == null) newLine = "\n";
		
		EventCard e=new EventCard(0);
		e.displayChoiceDescription();
		
		String expected = "Choice 0 :\n" + "Q1_choice 1\n"  + 
						  "Choice 1 :\n" + "Q1_choice 2\n"  + 
						  "Choice 2 :\n" + "Q1_choice 3\n"  +
						  "Choice 3 :\n" + "Q1_choice 4\n";
		
		assertEquals(expected,outContent.toString());
		
	}

	@Test
	//Basic path coverage for testing getPoint()
	public void testGetPoint_2pt() {
		EventCard event = new EventCard(1);
		int result = event.getPoint(0);
		assertEquals(result, 2);
	}
	
	@Test
	public void testGetPoint_1pt() {
		EventCard event = new EventCard(1);
		int result = event.getPoint(1);
		assertEquals(result, 1);
	}
	
	@Test
	public void testGetPoint_negative1() {
		EventCard event = new EventCard(1);
		int result = event.getPoint(2);
		assertEquals(result, -1);
	}
	
	@Test
	public void testGetPoint_negative2() {
		EventCard event = new EventCard(1);
		int result = event.getPoint(3);
		assertEquals(result, -2);
	}
	
	@Test 
	public void testGetDecisionMaker_0() {
		EventCard event = new EventCard(0);
		int result = event.getDecisionMaker();
		assertEquals(result, 0);
	}
	
	@Test 
	public void testGetDecisionMaker_4() {
		EventCard event = new EventCard(4);
		int result = event.getDecisionMaker();
		assertEquals(result, 4);
	}
	
	/* it should be error, but how to test?
	@Test 
	public void testGetDecisionMaker_5() {
		EventCard event = new EventCard(5);
		int result = event.getDecisionMaker();
		assertError(result, 5);
	}*/

	/*
	@Test 
	public void asdf() {
		EventCard event = new EventCard(4);
		int result = getField(event, "decisionMaker");
		assertEquals(result, 4);
	}
	*/
}
